﻿#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void game()
{
	int guess = 0;
	int r = rand()% 100 + 1;
	printf("该数字的范围为1~100，请开始猜数\n");
	
	while (1)
	{
		scanf("%d", &guess);
		if (guess < r)
		{
		printf("猜小了\n");
		}
		else if (guess > r)
		{
			printf("猜大了\n");
		}
		else
		{
			printf("恭喜你，猜对了\n");
			break;

		}
	}
}
int main()
{
	int n = 0;
	srand((unsigned int)time(NULL));
	do
	{
		printf("****************\n");
		printf("****1.enter*****\n");
		printf("****0.exit *****\n");
		printf("****************\n");
		printf("请选择：");
		scanf("%d",  &n);
		switch (n)
		{
		case 1:printf("游戏开始\n"); game(); break;
		case 0:printf("退出游戏\n"); break;
		default:printf("1为开始游戏 0为退出游戏，请重新选择\n");
		}
	}while (n);
}